import config from "@/config"
import http from "@/utils/request"

export default {
  // 日程安排
  getScheduleList: {
    url: `${config.API_URL}/schedule/list`,
    name: "根据月份获取日程列表",
    get: function (param) {
      return new Promise((resolve, reject) => {
        http.get(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  getAllSchedule: {
    url: `${config.API_URL}/schedule/listBySearch`,
    name: "获取全部日程列表",
    get: function (param) {
      return new Promise((resolve, reject) => {
        http.get(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  addSchedule: {
    url: `${config.API_URL}/schedule/add`,
    name: "添加日程",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  updateSchedule: {
    url: `${config.API_URL}/schedule/update`,
    name: "修改日程",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  deleteSchedule: {
    url: `${config.API_URL}/schedule/delete`,
    name: "删除日程",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  getScheduleForDay: {
    url: `${config.API_URL}/schedule/listForDay`,
    name: "用户某天的全部日程",
    get: function (data) {
      return new Promise((resolve, reject) => {
        http.get(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  }
}
